package org.example.java8time;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @Classname Test
 * @Description localDate.localTime和localDateTime相互转化
 * @Date 2021/2/4 2:49 下午
 * @Created by xiangjd
 */
public class Test {

    public static void main(String[] args) {
        //localDate.localTime转化成localDateTime
        LocalDate date = LocalDate.now();
        LocalTime time = LocalTime.now();
        LocalDateTime dateTimeFromDateAndTime = LocalDateTime.of(date, time);
        System.out.println(dateTimeFromDateAndTime);

        //localDateTime转化成localDate.localTime
        LocalDate dateFromDateTime = LocalDateTime.now().toLocalDate();
        LocalTime timeFromDateTime = LocalDateTime.now().toLocalTime();
        System.out.println(dateFromDateTime);
        System.out.println(timeFromDateTime);
    }
}
